define(function (require, exports, module) {
	var ListForm=function(){}
	ListForm.prototype.init=function(){
		var self=this;
		$("#exportButton").unbind("click")
		$("#exportButton").bind("click",function(event){return self.exportButtonClickHandle(event)})
		this.setNoneRecord();
	}
	
	ListForm.prototype.exportButtonClickHandle=function(event){
		//var formAction=document.getElementById("listForm").action;
		var formAction=$("#listForm").attr("action");
		$("#listForm").attr("action",$(event.target).attr("formaction"));
		document.getElementById("listForm").submit();
		$("#listForm").attr("action",formAction);
	}
	ListForm.reload=function(){
		$("#listForm").submit();
	}
	
	ListForm.prototype.setNoneRecord=function(){
		//noResults
		var listModule = document.getElementById("listForm");
		if(listModule==null || typeof listModule =="undefined"){
			return false;
		}
		var x = listModule.getElementsByTagName('tbody')[0].children.length;
		if( x == 0)
		{
			var divElement;
			divElement = document.createElement("div")
			divElement.className="noneRecord"
			divElement.innerHTML=("查无记录！")
			listModule.appendChild(divElement)
			$(divElement).css("width",$(listModule.getElementsByTagName('table')).width()+"px")
			$(listModule.getElementsByTagName('table')).parent().get(0).appendChild(divElement)
			
			var pagination = document.getElementById("pagination")
			if(pagination)
			{
				pagination.style.display="none";
			}
		}
	}
	
	//获得参数序列
	ListForm.prototype.getOrderSerializeArray=function(){
		var elementArray=$("#listForm #listModule thead input[type=hidden]")
		
		var serializeArray=Array();
		var serialize={};
		for(var i=0;i<elementArray.length;i++){
			var name=elementArray.get(i).name;
			var value=elementArray.get(i).value;

			serialize={}
			serialize.name=name;
			serialize.value=value;
			
			serializeArray.push(serialize);
		}
		return serializeArray;
	}
	
	ListForm.prototype.insertElement=function(element){
		var listForm=document.getElementById("listForm")
		try{listForm.insertBefore(element,listForm.firstChild);}catch(e){console.log(e)};
	}
	module.exports = ListForm;
});